/** <a href="http://www.cpupk.com/decompiler">Eclipse Class Decompiler</a> plugin, Copyright (c) 2017 Chen Chao. **/
package com.minierp.validator;

import com.minierp.model.SmsPhrase;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

public class SmsPhraseValidator implements Validator {
	public boolean supports(Class clazz) {
		return SmsPhrase.class.isAssignableFrom(clazz);
	}

	public void validate(Object obj, Errors errors) {
		SmsPhrase form = (SmsPhrase) obj;
		if (form.getContent() != null && !form.getContent().trim().equals("")) {
			if (form.getContent().length() >= 140) {
				errors.rejectValue("content", "", "『内容』不能超过140个字符");
			}
		} else {
			errors.rejectValue("content", "", "请输入『内容』");
		}

	}
}